package com.sdy.auth.biz.service.impl;

import com.sdy.common.utils.StringUtil;
import com.sdy.mvc.service.impl.BaseServiceImpl;
import com.sdy.auth.biz.mapper.SysResourceMapper;
import com.sdy.auth.biz.model.SysResource;
import com.sdy.auth.biz.service.SysResourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 系统资源表 服务实现类
 * </p>
 *
 * @author zzq
 * @since 2019-06-14
 */
@Slf4j
@Service
public class SysResourceServiceImpl extends BaseServiceImpl<SysResource> implements SysResourceService {
    @Autowired
    private SysResourceMapper sysResourceMapper;

    @Override
    public List<SysResource> findResourceWithAuthByRoleId(Integer roleId) {
        return sysResourceMapper.findResourceWithAuthByRoleId(roleId);
    }

    @Override
    public SysResource findAppByCode(String appCode) {
        if (StringUtil.isBlank(appCode)) {
            return null;
        }
        return lambdaQuery().eq(SysResource::getType, 1).eq(SysResource::getCode, appCode).one();
    }
}
